from django.db import models



class UserInfo(models.Model):
    username = models.CharField(max_length=10,verbose_name='姓名')
    password = models.CharField(max_length=10,verbose_name='密码')

class People(models.Model):
    name = models.CharField(max_length=10, blank=True, default='', verbose_name="姓名")
    age = models.CharField(max_length=10, blank=True, default='', verbose_name="年龄")
    sex = models.BooleanField(default=True, verbose_name="性别")
    user = models.ForeignKey(UserInfo,blank=True,null=True,on_delete=models.CASCADE,related_name='people')

class Goods(models.Model):
    HOBBY = (
        (1,"篮球"),
        (2,"足球"),
        (3,"乒乓球")
    )
    name = models.CharField(max_length=10,blank=True,default='',verbose_name="商品名称")
    datetime = models.DateTimeField(verbose_name="当前时间",auto_now=True)
    image = models.FileField(upload_to='goods/%Y/%m',verbose_name="商品图片")
    people = models.ForeignKey(People,blank=True,null=True,on_delete=models.CASCADE,related_name='goods')
    hobby = models.SmallIntegerField(verbose_name="爱好",choices=HOBBY,default=3)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'goods'
        verbose_name = "商品"
        verbose_name_plural = verbose_name

